package database;
import java.sql.*;
import java.util.*;
public class GetAllRows{
  public static void main(String[] args) {
    System.out.println("Getting All Rows from a table!");
    Connection con = null;
    String dbURL = "jdbc:postgresql://192.168.61.205:5432/license";
   // String db = " ";
    String driver = "org.postgresql.Driver";
    String username = "postgres";
    String password = " ";
    try{
      Class.forName(driver).newInstance();
      con = DriverManager.getConnection(dbURL, username, password);
      try{
        Statement st = con.createStatement();
        ResultSet res = st.executeQuery("SELECT * FROM  users");
        System.out.println("Emp_code: " + "\t" + "Emp_name: ");
        while (res.next()) {
         // int i = res.getInt("Emp_code");
          String s = res.getString(1);
          String s2 = res.getString(2);
          String s3 = res.getString(3);
          System.out.println(s2+  "\t\t" + s+s3);
        }
        con.close();
      }
      catch (SQLException s){
        System.out.println("SQL code does not execute.");
      }
    }
    catch (Exception e){
      e.printStackTrace();
    }
  }
}

